package com.readExcelImage;

import com.readExcelImage.bean.ExcelImageInfo;

import java.io.*;
import java.util.Map;

public class Test {
    public static void main(String[] args) throws IOException {
        Map<String, ExcelImageInfo> strMaps = ReadExcelUtil.readAllImage("C:\\Users\\wy\\Desktop\\烟花产品 2.xlsx");
        ExcelImageInfo excelImageInfo = strMaps.get("ID_B2C70D8C3FD241C2B0AD99B1B689EE3A");
        ExcelImageInfo excelImageInfo1 = strMaps.get("ID_DECE33583E1546BBAE02A868E42B3D60");
        ExcelImageInfo excelImageInfo2 = strMaps.get("ID_B2C70D8C3FD241C2B0AD99B1B689EE3A");
        InputStream imageInputStream = excelImageInfo.getNewImageInputStream();
        InputStream imageInputStream1 = excelImageInfo1.getNewImageInputStream();
        InputStream imageInputStream2 = excelImageInfo2.getNewImageInputStream();
        write(imageInputStream, "0");
        write(imageInputStream1, "1");
        write(imageInputStream2, "2");
    }

    public static void write(InputStream imageInputStream, String name) {
        // 缓冲区大小，可以根据需要调整
        byte[] buffer = new byte[1024];
        int bytesRead;

        try (FileOutputStream fileOutputStream = new FileOutputStream("C:\\Users\\wy\\Desktop\\新建文件夹\\" + name + ".jpg")) {
            while ((bytesRead = imageInputStream.read(buffer)) != -1) {
                fileOutputStream.write(buffer, 0, bytesRead);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
